package com.ynet.middleground.approve.identity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.GroupQuery;
import org.activiti.engine.impl.GroupQueryImpl;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.entity.GroupEntity;
import org.activiti.engine.impl.persistence.entity.GroupEntityManager;
import org.springframework.stereotype.Component;

import com.ynet.core.exception.BusinessException;

/**
 * @author liulx
 * @description 自定义用户组管理器
 * @date 2019-11-19 14:46
 */
@Component
public class CustomGroupEntityManager implements GroupEntityManager {

    @Override
    public Group createNewGroup(String s) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public GroupQuery createNewGroupQuery() {
        return new GroupQueryImpl(Context.getProcessEngineConfiguration().getCommandExecutor());
    }

    @Override
    public List<Group> findGroupByQueryCriteria(GroupQueryImpl groupQuery, Page page) {
        // Only support for groupMember() at the moment
        /* if (groupQuery.getUserId() != null) {
            return findGroupsByUser(groupQuery.getUserId());
        } else {
            throw new BusinessException("CustomGroupEntityManagerImpl当前不支持查询", "00001");
        }*/
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public long findGroupCountByQueryCriteria(GroupQueryImpl groupQuery) {
        return findGroupByQueryCriteria(groupQuery, null).size();
    }

    /**
     *
     * 
     * @param s
     * @return
     */
    @Override
    public List<Group> findGroupsByUser(String s) {
        List<Group> groups = new ArrayList<>();
        return groups;
    }

    @Override
    public List<Group> findGroupsByNativeQuery(Map<String, Object> map, int i, int i1) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public long findGroupCountByNativeQuery(Map<String, Object> map) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public boolean isNewGroup(Group group) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public GroupEntity create() {
        throw new BusinessException("该功能未实现", "00001");
    }

    /**
     *
     * 
     * @param s
     * @return
     */
    @Override
    public GroupEntity findById(String s) {
        return null;
    }

    @Override
    public void insert(GroupEntity entity) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public void insert(GroupEntity entity, boolean b) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public GroupEntity update(GroupEntity entity) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public GroupEntity update(GroupEntity entity, boolean b) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public void delete(String s) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public void delete(GroupEntity entity) {
        throw new BusinessException("该功能未实现", "00001");
    }

    @Override
    public void delete(GroupEntity entity, boolean b) {
        throw new BusinessException("该功能未实现", "00001");
    }
}
